package com.wuji1626.spark.rdd.transform

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object RDD_Transform_groupBy_lexicographical {

  def main(args: Array[String]): Unit = {
    // Step1: 准备环境
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("Operator")
    val sc = new SparkContext(sparkConf)


    // Step2: 算子 groupBy
    val rdd: RDD[String] = sc.makeRDD(List("Spark","Scala","Java","Python","PyCharm","Jupyter"),numSlices = 2)


    val groupRDD = rdd.groupBy(_.charAt(0))
    groupRDD.collect().foreach(println)

    // Step3: 关闭环境
    sc.stop()
  }

}
